<%@ page import="java.util.function.BiConsumer" %>
<%@ page import="java.io.IOException" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.stream.Collectors" %>
<%@ page import="java.util.AbstractMap" %>
<%@ page import="java.sql.Timestamp" %>
<%@ page import="java.sql.Time" %>
<%@ page import="java.time.LocalDateTime" %>
<%@ page import="com.gmono.managers.ArticleManager" %>
<%@ page import="com.gmono.managers.Article" %>
<%@ page import="com.gmono.managers.Common" %><%--
  Created by IntelliJ IDEA.
  User: cva
  Date: 18-12-28
  Time: 下午5:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%@include file="/Login/loginedUser.jsp"%>
<%
    request.setCharacterEncoding("UTF-8");
    Article a=new Article();
    a.setTitle(request.getParameter("title"));
    a.setContent(request.getParameter("content"));
    a.setDescribe(request.getParameter("describe"));
    a.setTime(Timestamp.valueOf(LocalDateTime.now()));
    a.setCategory(Integer.parseInt(request.getParameter("category")));
    a.setVisibility(true);
    a.setUserid(loginedUser.getId());
    //添加
    boolean isok=ArticleManager.addArticle(a);
    if(isok)
    {
        //在关联表中添加
//        Common.c.prepareStatement("insert into article_category(article_id, category_id) VALUES (?,?)")
//        Common.Update("insert into article_category(article_id, category_id) VALUES (?,?)",)
        response.sendRedirect("../backend/article.jsp");
    }
    else
    {
        out.print("文件添加错误!");
    }
%>

